import cv2
import numpy as np
from scipy import ndimage

kernel_3x3 = np.array( [
    [-1, -1, -1],
    [-1,  8, -1],
    [-1, -1, -1],
] )

kernel_5x5 = np.array([
    [-1, -1, -1, -1, -1],
    [-1,  1,  2,  1, -1],
    [-1,  2,  4,  2, -1],
    [-1,  1,  2,  1, -1],
    [-1, -1, -1, -1, -1]
])

if __name__ == '__main__':

    img = cv2.imread('lz-swk.jpeg', 0)

    blurred_img = cv2.blur(img, (10, 10))

    k3 = ndimage.convolve(img, kernel_3x3)
    k5 = ndimage.convolve(img, kernel_5x5)

    gaussian_blurred = cv2.GaussianBlur(img, (11, 11), 0)
    g_hpf = img - gaussian_blurred

    cv2.imshow(u'原始图像', img)
    cv2.imshow(u'模糊图像', blurred_img)
    cv2.imshow(u'3x3', k3)
    cv2.imshow(u'5x5', k5)
    cv2.imshow(u'g_hpf', g_hpf)
    cv2.waitKey()
    cv2.destroyAllWindows()


